home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 3006 / 3006.xpi / chrome / dwhelper.jar / content / video-format.xml < prev    next >
Extensible Markup Language  |  2010-01-15  |  27KB  |  1,104 lines

  1. <?xml version="1.0"?>
  2. <!-- *****************************************************************************
  3.  *            Copyright (c) 2006-2009 Michel Gutierrez. All Rights Reserved.
  4.  ****************************************************************************** -->
  5.  
  6. <!DOCTYPE bindings SYSTEM "chrome://dwhelper/locale/dwhelper.dtd" >
  7.  
  8. <bindings xmlns="http://www.mozilla.org/xbl"
  9.     xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  10.     xmlns:html="http://www.w3.org/1999/xhtml"
  11.     xmlns:xbl="http://www.mozilla.org/xbl">
  12.  
  13.     <binding id="VideoFormat" extends="widgets.xml#widget">
  14.  
  15.         <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  16.  
  17.             <tabbox flex="1">
  18.                 <tabs>
  19.                     <tab label="&title.video-format.general;"/>
  20.                     <tab label="&title.video-format.advanced;"/>
  21.                 </tabs>
  22.                 <tabpanels flex="1">
  23.                     <tabpanel flex="1">
  24.                         <grid>
  25.                             <columns>
  26.                                 <column/>
  27.                                 <column flex="1"/>
  28.                             </columns>
  29.                             <rows anonid="xRows"/>
  30.                         </grid>
  31.                         <spacer flex="1"/>
  32.                     </tabpanel>
  33.                     <tabpanel flex="1">
  34.                         <grid>
  35.                             <columns>
  36.                                 <column/>
  37.                                 <column flex="1"/>
  38.                             </columns>
  39.                             <rows anonid="xRowsAdv"/>
  40.                         </grid>
  41.                         <spacer flex="1"/>
  42.                     </tabpanel>
  43.                 </tabpanels>
  44.             </tabbox>
  45.             <children style="display: none;"/>
  46.         </xbl:content>
  47.  
  48.         <implementation>
  49.  
  50.             <constructor>
  51.                 <![CDATA[
  52. this.paramToWidget={};
  53. this.paramToFormat={};
  54. this.paramWidgets=[];
  55. this.hide2ndPassWidgets=[];
  56. this.extraArgsWidget=null;
  57. this.extensionWidget=null;
  58. this.defaultExtensionWidget=null;
  59.  
  60. this.formats=[
  61.     {
  62.         args: ["f",1],
  63.         permanent: true,
  64.         defaultExtension: true,
  65.         hide2ndPass: true,
  66.         ilabel: "video-format.output-format",
  67.         type: "VideoFormatList",
  68.         config: [{value:'avi',label:'AVI format'},{value:'3g2',label:'3GP2 format'},{value:'3gp',label:'3GP format'},{value:'RoQ',label:'Id RoQ format'},{value:'ac3',label:'raw ac3'},{value:'adts',label:'ADTS AAC'},{value:'aiff',label:'Audio IFF'},{value:'alaw',label:'pcm A law format'},{value:'amr',label:'3gpp amr file format'},{value:'asf',label:'ASF format'},{value:'au',label:'SUN AU Format'},{value:'dv',label:'DV video format'},{value:'dvd',label:'MPEG2 PS format (DVD VOB)'},{value:'ffm',label:'FFM format'},{value:'flac',label:'raw flac'},{value:'flv',label:'FLV format'},{value:'gif',label:'GIF Animation'},{value:'gxf',label:'GXF format'},{value:'h261',label:'raw h261'},{value:'h263',label:'raw h263'},{value:'h264',label:'raw H264 video format'},{value:'m4v',label:'raw MPEG4 video format'},{value:'matroska',label:'Matroska File Format'},{value:'mjpeg',label:'MJPEG video'},{value:'mmf',label:'MMF format'},{value:'mov',label:'MOV format'},{value:'mp2',label:'MPEG audio layer 2'},{value:'mp3',label:'MPEG audio layer 3'},{value:'mp4',label:'MP4 format'},{value:'mpeg',label:'MPEG1 System format'},{value:'mpeg1video',label:'MPEG video'},{value:'mpeg2video',label:'MPEG2 video'},{value:'mpegts',label:'MPEG2 transport stream format'},{value:'mpjpeg',label:'Mime multipart JPEG format'},{value:'mulaw',label:'pcm mu law format'},{value:'nut',label:'NUT format'},{value:'ogg',label:'Ogg format'},{value:'psp',label:'psp mp4 format'},{value:'rawvideo',label:'raw video format'},{value:'rm',label:'RM format'},{value:'rtp',label:'RTP output format'},{value:'svcd',label:'MPEG2 PS format (VOB)'},{value:'swf',label:'Flash format'},{value:'vcd',label:'MPEG1 System format (VCD)'},{value:'vob',label:'MPEG2 PS format (VOB)'},{value:'voc',label:'Creative Voice File format'},{value:'wav',label:'WAV format'},]
  69.     },
  70.     {
  71.         extensionWidget: true,
  72.         hide2ndPass: true,
  73.         ilabel: "video-format.extension",
  74.         type: "VideoFormatText"
  75.     },
  76.     {
  77.         args: ["vcodec",1],
  78.         ilabel: "video-format.video-codec",
  79.         type: "VideoFormatList",
  80.         config: [{value: 'asv1'},{value: 'asv2'},{value: 'bmp'},{value: 'dnxhd'},{value: 'dvvideo'},{value: 'ffv1'},{value: 'ffvhuff'},{value: 'flashsv'},{value: 'flv'},{value: 'gif'},{value: 'h261'},{value: 'h263'},{value: 'h263p'},{value: 'huffyuv'},{value: 'jpegls'},{value: 'libtheora'},{value: 'libx264'},{value: 'libxvid'},{value: 'ljpeg'},{value: 'mjpeg'},{value: 'mpeg1video'},{value: 'mpeg2video'},{value: 'mpeg4'},{value: 'msmpeg4'},{value: 'msmpeg4v1'},{value: 'msmpeg4v2'},{value: 'pam'},{value: 'pbm'},{value: 'pgm'},{value: 'pgmyuv'},{value: 'png'},{value: 'ppm'},{value: 'qtrle'},{value: 'rawvideo'},{value: 'roqvideo'},{value: 'rv10'},{value: 'rv20'},{value: 'sgi'},{value: 'snow'},{value: 'svq1'},{value: 'targa'},{value: 'tiff'},{value: 'wmv1'},{value: 'wmv2'},{value: 'zlib'},{value: 'zmbv'}]
  81.     },
  82.     {
  83.         args: ["acodec",1],
  84.         ilabel: "video-format.audio-codec",
  85.         type: "VideoFormatList",
  86.         config: [{value:'ac3'},{value:'adpcm_adx'},{value:'adpcm_ima_wav'},{value:'adpcm_ms'},{value:'adpcm_swf'},{value:'adpcm_yamaha'},{value:'flac'},{value:'g726'},{value:'libamr_nb'},{value:'libamr_wb'},{value:'libfaac'},{value:'libgsm'},{value:'libgsm_ms'},{value:'libmp3lame'},{value:'libvorbis'},{value:'mp2'},{value:'pcm_alaw'},{value:'pcm_mulaw'},{value:'pcm_zork'},{value:'roq_dpcm'},{value:'sonic'},{value:'sonicls'},{value:'vorbis'},{value:'wmav1'},{value:'wmav2'}]
  87.     },
  88.     {
  89.         args: ["b",1],
  90.         ilabel: "video-format.bitrate",
  91.         type: "VideoFormatInteger",
  92.     },
  93.     {
  94.         args: ["sameq",0],
  95.         ilabel: "video-format.same-quality",
  96.         type: "VideoFormatBool",
  97.     },
  98.     {
  99.         args: ["r",1],
  100.         ilabel: "video-format.frame-rate",
  101.         type: "VideoFormatText",
  102.     },
  103.     {
  104.         args: ["s",1],
  105.         advanced: true,
  106.         ilabel: "video-format.frame-size",
  107.         type: "VideoFormatText",
  108.     },
  109.     {
  110.         args: ["ar",1],
  111.         advanced: true,
  112.         ilabel: "video-format.audio-freq",
  113.         type: "VideoFormatText",
  114.     },
  115.     {
  116.         args: ["target",1],
  117.         advanced: true,
  118.         ilabel: "video-format.target",
  119.         type: "VideoFormatList",
  120.         config: [{value:'pal-vcd'},{value:'pal-svcd'},{value:'pal-dvd'},{value:'pal-dv'},{value:'pal-dv50'},{value:'ntsc-vcd'},{value:'ntsc-svcd'},{value:'ntsc-dvd'},{value:'ntsc-dv'},{value:'ntsc-dv50'},{value:'film-vcd'},{value:'film-svcd'},{value:'film-dvd'},{value:'film-dv'},{value:'film-dv50'}]
  121.     },
  122.     {
  123.         args: ["aspect",1],
  124.         advanced: true,
  125.         ilabel: "video-format.aspect",
  126.         type: "VideoFormatList",
  127.         config: [{value:'4:3'},{value:'16:9'}]
  128.     },
  129.     {
  130.         args: ["qmin",1],
  131.         advanced: true,
  132.         ilabel: "video-format.qmin",
  133.         type: "VideoFormatText",
  134.     },
  135.     {
  136.         args: ["qmax",1],
  137.         advanced: true,
  138.         ilabel: "video-format.qmax",
  139.         type: "VideoFormatText",
  140.     },
  141.     {
  142.         args: ["vtag",1],
  143.         advanced: true,
  144.         ilabel: "video-format.vtag",
  145.         type: "VideoFormatText",
  146.     },
  147.     {
  148.         extraArgsWidget: true,
  149.         permanent: true,
  150.         advanced: true,
  151.         ilabel: "video-format.extra-args",
  152.         type: "VideoFormatText",
  153.     },
  154. ];
  155. for(var i in this.formats) {
  156.     var format=this.formats[i];
  157.     
  158.     var row=document.createElement("row");
  159.     row.setAttribute("align","center");
  160.     var label;
  161.     if(format.ilabel!=null) {
  162.         label=document.createElement("label");
  163.         label.setAttribute("value",DWHUtil.getText(format.ilabel));
  164.     } else if(format.label!=null) {
  165.         label=document.createElement("label");
  166.         label.setAttribute("value",format.label);
  167.     } else {
  168.         label=document.createElement("spacer");    
  169.     }
  170.     row.appendChild(label);
  171.  
  172.     var widget=document.createElement(format.type);
  173.     if(format.config) {
  174.         window.setTimeout(function(widget,config) {
  175.             widget.setConfig(config);
  176.         },0,widget,format.config);
  177.     }
  178.     if(format.permanent)
  179.         widget.setAttribute("permanent","true");
  180.     row.appendChild(widget);
  181.  
  182.     if(format.args) {
  183.         this.paramToWidget[format.args[0]]=widget;
  184.         this.paramToFormat[format.args[0]]=format;
  185.         this.paramWidgets.push(widget);
  186.     }    
  187.     if(format.extraArgsWidget)
  188.         this.extraArgsWidget=widget;
  189.     if(format.extensionWidget)
  190.         this.extensionWidget=widget;
  191.     if(format.defaultExtension)
  192.         this.defaultExtensionWidget=widget;
  193.  
  194.     if(format.advanced)
  195.         this.xRowsAdv.appendChild(row);
  196.     else
  197.         this.xRows.appendChild(row);
  198.         
  199.     if(format.hide2ndPass)
  200.         this.hide2ndPassWidgets.push(row);
  201. }
  202.                 ]]>
  203.             </constructor>
  204.  
  205.             <destructor>
  206.                 <![CDATA[
  207.                 ]]>
  208.             </destructor>
  209.  
  210.             <method name="secondPassMode">
  211.                 <parameter name="sec"/>
  212.                 <body>
  213.                 <![CDATA[
  214. for(var i=0;i<this.hide2ndPassWidgets.length;i++) {
  215.     this.hide2ndPassWidgets[i].setAttribute("hidden",""+sec);
  216. }
  217.                 ]]>
  218.                 </body>
  219.             </method>
  220.  
  221.  
  222.             <property name="value">  
  223.                 <setter>
  224.                 <![CDATA[
  225. for(var i=0;i<this.paramWidgets.length;i++) {
  226.     this.paramWidgets[i].value=null;
  227. }
  228. if(this.extraArgsWidget)
  229.     this.extraArgsWidget.value=null;
  230. if(this.extensionWidget)
  231.     this.extensionWidget.value=null;
  232.                 
  233. if(!/^[a-zA-Z0-9]*?\/.*$/.test(val))
  234.     val="wmv/-acodec wmav1 -b 1000kbps -f asf -vcodec wmv1";
  235.     
  236. var m=/^([a-zA-Z0-9]*?)\/(.*)/.exec(val);
  237. var extension=m[1];
  238. if(extension.length==0)
  239.     extension="avi";
  240.  
  241. var extraArgs="";
  242.  
  243. var v=m[2].replace(/ +/g," ");
  244. v=/^ *(.*?) *$/.exec(v)[1];
  245. var params=v.split(" ");
  246.  
  247. var cWidget=null;
  248. var initial=true;
  249.  
  250. for(var i=0;i<params.length;i++) {
  251.     var arg=params[i];
  252.     if(initial) {
  253.         if(arg[0]=='-') {
  254.             cWidget=this.paramToWidget[arg.substr(1)];
  255.             if(cWidget) {
  256.                 if(this.paramToFormat[arg.substr(1)].args[1]==0) {
  257.                     cWidget.value=true;
  258.                 } else {
  259.                     initial=false;
  260.                 }
  261.             } else {
  262.                 extraArgs+=arg+" ";
  263.             }
  264.         } else {
  265.             extraArgs+=arg+" ";
  266.         }
  267.     } else {
  268.         cWidget.value=arg;
  269.         initial=true;
  270.     }
  271. }
  272.  
  273. if(this.extraArgsWidget) {
  274.     this.extraArgsWidget.value=/^ *(.*?) *$/.exec(extraArgs)[1];
  275. }
  276.  
  277. if(this.extensionWidget) {
  278.     if(this.defaultExtensionWidget) {
  279.         if(extension!=this.defaultExtensionWidget.value)
  280.             this.extensionWidget.value=extension;
  281.         else
  282.             this.extensionWidget.value=null;            
  283.     } else {
  284.         this.extensionWidget.value=extension;
  285.     }
  286. }
  287.                 ]]> 
  288.                 </setter>
  289.                 <getter>
  290.                 <![CDATA[
  291. var extension=null;
  292. if(this.extensionWidget)
  293.     extension=this.extensionWidget.value;
  294. if(extension==null) {
  295.     if(this.defaultExtensionWidget)
  296.         extension=this.defaultExtensionWidget.value;
  297. }
  298. if(extension==null)
  299.     extension="avi";
  300. var value=extension+"/";
  301. var params=[];
  302. for(var i in this.paramToFormat) {
  303.     var format=this.paramToFormat[i];
  304.     var widget=this.paramToWidget[i];
  305.     var wValue=widget.value;
  306.     if(format.args[1]==0) {
  307.         if(wValue==true)
  308.             params.push("-"+i);
  309.     } else {
  310.         if(wValue!=null && wValue.length>0) {
  311.             params.push("-"+i+" "+wValue);
  312.         }    
  313.     }
  314. }
  315. if(this.extraArgsWidget) {
  316.     var wValue=/^ *(.*?) *$/.exec(this.extraArgsWidget.value)[1];
  317.     wValue=wValue.replace(/ +/g," ");
  318.     if(wValue.length>0) {
  319.         var eParams=wValue.split(" ");
  320.         for(var i=0;i<eParams.length;i++) {
  321.             if(eParams[i].length>0) {
  322.                 if(eParams[i][0]=='-') {
  323.                     params.push(eParams[i]);
  324.                 } else if(params.length>0) {
  325.                     params[params.length-1]+=" "+eParams[i];
  326.                 }
  327.             }
  328.         }
  329.     }
  330. }
  331. if(params.length>0) {
  332.     params.sort();
  333.     value=value+params.join(" ");
  334. }
  335. return value;
  336.                 ]]> 
  337.                 </getter>
  338.             </property>
  339.  
  340.         </implementation>
  341.         
  342.     </binding>
  343.  
  344.     <binding id="VideoFormatWidget" extends="widgets.xml#widget">
  345.  
  346.         <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  347.             <children style="display: none;"/>
  348.         </xbl:content>
  349.  
  350.         <implementation>
  351.  
  352.             <constructor>
  353.                 <![CDATA[
  354. this.updateEnabled();
  355.                 ]]>
  356.             </constructor>
  357.  
  358.             <destructor>
  359.                 <![CDATA[
  360.                 ]]>
  361.             </destructor>
  362.  
  363.             <method name="updateEnabled">
  364.                 <body>
  365.                 <![CDATA[
  366. if(this.getAttribute("permanent")=="true") {
  367.     if(this.xEnabled) {
  368.         this.xEnabled.setAttribute("hidden","true");
  369.     }
  370.     if(this.xItem) {
  371.         this.xItem.setAttribute("hidden","false");
  372.     }
  373. } else {
  374.     if(this.xEnabled) {
  375.         var enabled=this.xEnabled.value;
  376.         if(this.xItem) {
  377.             this.xItem.setAttribute("hidden",""+!enabled);
  378.         }
  379.     }
  380. }
  381.                 ]]>
  382.                 </body>
  383.             </method>
  384.             
  385.             <method name="setConfig">
  386.                 <parameter name="config"/>
  387.                 <body>
  388.                 <![CDATA[
  389.                 ]]>
  390.                 </body>
  391.             </method>
  392.             
  393.             <property name="value">  
  394.                 <setter>
  395.                 <![CDATA[
  396. if(this.xItem) {
  397.     if(this.xEnabled) {
  398.         if(val==null)
  399.             this.xEnabled.value=false;
  400.         else
  401.             this.xEnabled.value=true;
  402.     }
  403.     this.xItem.value=val;
  404.     this.updateEnabled();
  405. }
  406.                 ]]> 
  407.                 </setter>
  408.                 <getter>
  409.                 <![CDATA[
  410. if(this.getAttribute("permanent")!="true" && this.xEnabled && this.xEnabled.value==false)
  411.     return null;
  412. if(this.xItem)
  413.     return /^ *(.*?) *$/.exec(this.xItem.value)[1];
  414. else
  415.     return null;
  416.                 ]]> 
  417.                 </getter>
  418.             </property>
  419.         </implementation>
  420.         
  421.         <handlers>
  422.         
  423.             <handler event="vfenable">
  424.                 <![CDATA[
  425. this.updateEnabled();
  426.                 ]]>
  427.             </handler>
  428.         
  429.         </handlers>
  430.         
  431.     </binding>
  432.  
  433.     <binding id="VideoFormatCheckbox" extends="widgets.xml#widget">
  434.  
  435.         <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  436.             <vbox>
  437.                 <spacer flex="1"/>
  438.                 <html:input type="checkbox" anonid="xCheckbox"/>
  439.                 <spacer flex="1"/>
  440.             </vbox>                
  441.             <children style="display: none;"/>
  442.         </xbl:content>
  443.  
  444.         <implementation>
  445.  
  446.             <property name="value">  
  447.                 <setter>
  448.                 <![CDATA[
  449. if(this.xCheckbox)
  450.     this.xCheckbox.checked=(val==null)?false:val;
  451.                 ]]> 
  452.                 </setter>
  453.                 <getter>
  454.                 <![CDATA[
  455. return this.xCheckbox?this.xCheckbox.checked:false;
  456.                 ]]> 
  457.                 </getter>
  458.             </property>
  459.  
  460.         </implementation>
  461.         
  462.         <handlers>
  463.         
  464.             <handler event="change">
  465.                 <![CDATA[
  466. this.fireEvent("vfenable");
  467.                 ]]>
  468.             </handler>
  469.         
  470.         </handlers>
  471.         
  472.     </binding>
  473.     <binding id="VideoFormatList" extends="#VideoFormatWidget">
  474.  
  475.         <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  476.             <hrow>
  477.                 <VideoFormatCheckbox anonid="xEnabled"/>
  478.                 <menulist anonid="xItem">
  479.                     <menupopup anonid="xPopup"/>
  480.                 </menulist>
  481.             </hrow>
  482.             <children style="display: none;"/>
  483.         </xbl:content>
  484.  
  485.         <implementation>
  486.  
  487.             <constructor>
  488.                 <![CDATA[
  489.                 ]]>
  490.             </constructor>
  491.  
  492.             <destructor>
  493.                 <![CDATA[
  494.                 ]]>
  495.             </destructor>
  496.             
  497.             <method name="setConfig">
  498.                 <parameter name="config"/>
  499.                 <body>
  500.                 <![CDATA[
  501. for(var i in config) {
  502.     var item=config[i];
  503.     var menuitem=document.createElement("menuitem");
  504.     var label;
  505.     if(item.ilabel) {
  506.         label=DWHUtil.getText(item.ilabel);
  507.     } else if(item.label) {
  508.         label=item.label;
  509.     } else {
  510.         label=item.value;
  511.     }
  512.     menuitem.setAttribute("label",label);
  513.     menuitem.setAttribute("value",item.value);
  514.     this.xPopup.appendChild(menuitem);
  515. }
  516.                 ]]>
  517.                 </body>
  518.             </method>
  519.  
  520.             <property name="value">  
  521.                 <setter>
  522.                 <![CDATA[
  523. if(val==null)
  524.     this.xEnabled.value=false;
  525. else
  526.     this.xEnabled.value=true;
  527. this.xItem.selectedIndex=-1;
  528. this.xItem.value=val;
  529. this.updateEnabled();
  530.                 ]]> 
  531.                 </setter>
  532.                 <getter>
  533.                 <![CDATA[
  534. if(this.getAttribute("permanent")!="true" && this.xEnabled && this.xEnabled.value==false)
  535.     return null;
  536. if(this.xItem)
  537.     return /^ *(.*?) *$/.exec(this.xItem.value)[1];
  538. else
  539.     return null;
  540.                 ]]> 
  541.                 </getter>
  542.             </property>
  543.  
  544.         </implementation>
  545.         
  546.         <handlers>
  547.         
  548.             <handler event="DOMAttrModified">
  549.                 <![CDATA[
  550. if(event.attrName=="hidden") {
  551.     if(this.xItem.selectedIndex<0)
  552.         this.xItem.selectedIndex=0;
  553. }
  554.                 ]]>
  555.             </handler>
  556.         
  557.         </handlers>
  558.         
  559.  
  560.     </binding>
  561.  
  562.     <binding id="VideoFormatText" extends="#VideoFormatWidget">
  563.  
  564.         <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  565.             <hrow flex="1">
  566.                 <VideoFormatCheckbox anonid="xEnabled"/>
  567.                 <textbox anonid="xItem" flex="1"/>
  568.             </hrow>
  569.             <children style="display: none;"/>
  570.         </xbl:content>
  571.  
  572.         <implementation>
  573.  
  574.             <constructor>
  575.                 <![CDATA[
  576.                 ]]>
  577.             </constructor>
  578.  
  579.             <destructor>
  580.                 <![CDATA[
  581.                 ]]>
  582.             </destructor>
  583.  
  584.         </implementation>
  585.         
  586.     </binding>
  587.  
  588.     <binding id="VideoFormatInteger" extends="#VideoFormatText">
  589.  
  590.         <implementation>
  591.  
  592.             <constructor>
  593.                 <![CDATA[
  594.                 ]]>
  595.             </constructor>
  596.  
  597.             <destructor>
  598.                 <![CDATA[
  599.                 ]]>
  600.             </destructor>
  601.  
  602.         </implementation>
  603.         
  604.     </binding>
  605.  
  606.     <binding id="VideoFormatBool" extends="#VideoFormatWidget">
  607.  
  608.         <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  609.             <VideoFormatCheckbox anonid="xEnabled"/>
  610.             <children style="display: none;"/>
  611.         </xbl:content>
  612.  
  613.         <implementation>
  614.  
  615.             <constructor>
  616.                 <![CDATA[
  617.                 ]]>
  618.             </constructor>
  619.  
  620.             <destructor>
  621.                 <![CDATA[
  622.                 ]]>
  623.             </destructor>
  624.  
  625.             <property name="value">  
  626.                 <setter>
  627.                 <![CDATA[
  628. if(this.xEnabled)
  629.     this.xEnabled.value=val;
  630.                 ]]> 
  631.                 </setter>
  632.                 <getter>
  633.                 <![CDATA[
  634. if(this.xEnabled)
  635.     return this.xEnabled.value;
  636. return false;
  637.                 ]]> 
  638.                 </getter>
  639.             </property>
  640.  
  641.         </implementation>
  642.         
  643.     </binding>
  644.  
  645.     <binding id="VideoFormatPanel" extends="widgets.xml#widget">
  646.  
  647.         <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  648.             <hbox flex="1">
  649.                 <FormatConfigList anonid="xList" flex="1"/>
  650.                 <button
  651.                     anonid="xShow" 
  652.                     label="&button.video-format.show-details;" 
  653.                     oncommand="this.parentNode.parentNode.showDetails()"/>
  654.             </hbox>
  655.             <children style="display: none;"/>
  656.         </xbl:content>
  657.  
  658.         <implementation>
  659.  
  660.             <constructor>
  661.                 <![CDATA[
  662.                 ]]>
  663.             </constructor>
  664.  
  665.             <method name="showDetails">
  666.                 <body>
  667.                 <![CDATA[
  668. var data={
  669.     format: this.value
  670. }
  671. openDialog("chrome://dwhelper/content/video-format.xul","dwhelper-video-format","chrome,centerscreen,modal",data);
  672. if(data.ok) {
  673.     this.value=data.format;
  674. this.xList.updateFormat();
  675.                 ]]>
  676.                 </body>
  677.             </method>
  678.  
  679.             <property name="value">  
  680.                 <setter>
  681.                 <![CDATA[
  682. this.xList.value=val;
  683.                 ]]> 
  684.                 </setter>
  685.                 <getter>
  686.                 <![CDATA[
  687. return this.xList.value;
  688.                 ]]> 
  689.                 </getter>
  690.             </property>
  691.  
  692.             <method name="isValid">
  693.                 <body>
  694.                 <![CDATA[
  695. var needReg=/(?: |\/)-f mp3(?: |$)/.test(this.value);
  696. if(needReg==true) {
  697.     var props=this.convertMgr.getInfo();
  698.     var unregistered=props.get("unregistered",Components.interfaces.nsISupportsPRBool).data;
  699.     if(unregistered) {
  700.         this.util.alertWarning(this.util.getText("message.converter.need-registration"));
  701.         return false;
  702.     }
  703. }
  704. return true;
  705.                 ]]>
  706.                 </body>
  707.             </method>
  708.  
  709.  
  710.  
  711.         </implementation>
  712.  
  713.     </binding>
  714.  
  715.     <binding id="FormatConfigList" extends="widgets.xml#widget">
  716.  
  717.         <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  718.             <hbox flex="1">
  719.                 <menulist anonid="xList"
  720.                     oncommand="this.parentNode.parentNode.itemSelected()" flex="1">
  721.                     <menupopup anonid="xPopup"
  722.                         datasources="rdf:null"
  723.                         ref="http://downloadhelper.net/1.0#conv-confs">
  724.                             <template>
  725.                                 <rule>
  726.                                     <menuitem
  727.                                         uri="rdf:*"
  728.                                         label="rdf:http://downloadhelper.net/1.0#label" 
  729.                                         value="rdf:http://downloadhelper.net/1.0#value" 
  730.                                         flex="1"
  731.                                         />
  732.                                 </rule>
  733.                             </template>
  734.                     </menupopup>
  735.                 </menulist>
  736.                 <PopupButton anonid="xOps" hidden="true" image="chrome://dwhelper/skin/config.png">
  737.                     <menuitem anonid="xNameBut" 
  738.                         label="&button.video-format.name;" 
  739.                         oncommand="setTimeout(function(_t){_t.nameConfig();},0,this.parentNode.parentNode.parentNode)"/>
  740.                     <menuitem anonid="xRenameBut" 
  741.                         label="&button.video-format.rename;" 
  742.                         oncommand="setTimeout(function(_t){_t.renameConfig();},0,this.parentNode.parentNode.parentNode)"/>
  743.                     <menuitem anonid="xForgetBut" 
  744.                         label="&button.video-format.forget;" 
  745.                         oncommand="setTimeout(function(_t){_t.forgetConfig();},0,this.parentNode.parentNode.parentNode)"/>
  746.                     <menuseparator/>
  747.                     <menuitem anonid="xDefaultBut" 
  748.                         label="&button.video-format.default;" 
  749.                         oncommand="setTimeout(function(_t){_t.setDefault();},0,this.parentNode.parentNode.parentNode)"/>
  750.                 </PopupButton>
  751.             </hbox>
  752.             <children style="display: none;"/>
  753.         </xbl:content>
  754.  
  755.         <implementation>
  756.  
  757.             <constructor>
  758.                 <![CDATA[
  759. this.localstore=Components.classes["@mozilla.org/rdf/datasource;1?name=local-store"].
  760.             getService(Components.interfaces.nsIRDFDataSource);
  761. this.util.setDatasource(this.xPopup,this.localstore);
  762. if(this.getAttribute("confops")=="true")
  763.     this.xOps.setAttribute("hidden","false");
  764.                 ]]>
  765.             </constructor>
  766.  
  767.             <destructor>
  768.                 <![CDATA[
  769.                 ]]>
  770.             </destructor>
  771.  
  772.             <method name="setDefaultConfigs">
  773.                 <body>
  774.                 <![CDATA[
  775. this.convertMgr.setDefaultConfigs();
  776.                 ]]>
  777.                 </body>
  778.             </method>
  779.  
  780.  
  781.             <method name="clearConfs">
  782.                 <body>
  783.                 <![CDATA[
  784. this.convertMgr.clearConfigs(false);
  785.                 ]]>
  786.                 </body>
  787.             </method>
  788.             
  789.             <method name="updateFormat">
  790.                 <body>
  791.                 <![CDATA[
  792. var label=null;
  793. var confs=this.util.getChildResourcesS(this.localstore,this.NS+"conv-confs",{});
  794. for(var i=0;i<confs.length;i++) {
  795.     if(this._value==this.util.getPropertyValueRS(this.localstore,confs[i],this.NS+"value")) {
  796.         label=this.util.getPropertyValueRS(this.localstore,confs[i],this.NS+"label");
  797.         this.namedFormatRes=confs[i];
  798.         break;
  799.     }
  800. }
  801. if(label==null) {
  802.     this.xNameBut.setAttribute("hidden","false");
  803.     this.xRenameBut.setAttribute("hidden","true");
  804.     this.xForgetBut.setAttribute("hidden","true");
  805.     this.namedFormatRes=null;
  806.     var ext="avi";
  807.     try {
  808.         ext=/^(.*?)\/.*$/.exec(this._value)[1];
  809.     } catch(e) {}
  810.     label=DWHUtil.getFText("label.video-format.custom",[ext.toUpperCase()],{});
  811. } else {
  812.     this.xNameBut.setAttribute("hidden","true");
  813.     this.xRenameBut.setAttribute("hidden","false");
  814.     this.xForgetBut.setAttribute("hidden","false");
  815. }
  816. this.xList.setAttribute("label",label);
  817. this.rebuild();
  818.                 ]]>
  819.                 </body>
  820.             </method>
  821.  
  822.             <method name="itemSelected">
  823.                 <body>
  824.                 <![CDATA[
  825. this.value=this.xList.value;
  826.  
  827. setTimeout(function(_this) {
  828.     var evt = document.createEvent("Events");
  829.     evt.initEvent("dwhelper-confselect", true, true);
  830.     _this.dispatchEvent(evt);
  831. },0,this);
  832.                 ]]>
  833.                 </body>
  834.             </method>
  835.  
  836.             <property name="value">  
  837.                 <setter>
  838.                 <![CDATA[
  839. this._value=val;
  840. this.updateFormat();
  841.                 ]]> 
  842.                 </setter>
  843.                 <getter>
  844.                 <![CDATA[
  845. return this._value;
  846.                 ]]> 
  847.                 </getter>
  848.             </property>
  849.             
  850.             <method name="setDefault">
  851.                 <body>
  852.                 <![CDATA[
  853. if(confirm(this.util.getText("confirm.video-format.back-to-default"))) {
  854.     this.clearConfs(); 
  855.     this.setDefaultConfigs();
  856.     this.updateFormat();
  857. }
  858.                 ]]>
  859.                 </body>
  860.             </method>
  861.  
  862.             <method name="nameConfig">
  863.                 <body>
  864.                 <![CDATA[
  865. if(this.namedFormatRes!=null)
  866.     return;
  867. var name=prompt(this.util.getText("prompt.video-format.config-name"),"");
  868. if(name!=null && name.length>0) {
  869.     var convConf=this.util.createNodeSS(this.localstore,this.NS+"conv-confs",null);
  870.     this.util.setPropertyValueRS(this.localstore,convConf,this.NS+"value",this.value);
  871.     this.util.setPropertyValueRS(this.localstore,convConf,this.NS+"label",name);
  872. }
  873. this.updateFormat();
  874.                 ]]>
  875.                 </body>
  876.             </method>
  877.  
  878.             <method name="renameConfig">
  879.                 <body>
  880.                 <![CDATA[
  881. if(this.namedFormatRes==null)
  882.     return;
  883. var name=prompt(this.util.getText("prompt.video-format.config-name"),
  884.     this.util.getPropertyValueRS(this.localstore,this.namedFormatRes,this.NS+"label"));
  885. if(name!=null && name.length>0)
  886.     this.util.setPropertyValueRS(this.localstore,this.namedFormatRes,this.NS+"label",name);
  887. this.updateFormat();
  888.                 ]]>
  889.                 </body>
  890.             </method>
  891.  
  892.             <method name="forgetConfig">
  893.                 <body>
  894.                 <![CDATA[
  895. if(this.namedFormatRes==null)
  896.     return;
  897. this.util.removeReference(this.localstore,this.namedFormatRes);
  898. this.updateFormat();
  899.                 ]]>
  900.                 </body>
  901.             </method>
  902.  
  903.             <method name="rebuild">
  904.                 <body>
  905.                 <![CDATA[
  906. this.xPopup.builder.rebuild();
  907.                 ]]>
  908.                 </body>
  909.             </method>
  910.  
  911.  
  912.         </implementation>
  913.         
  914.     </binding>
  915.  
  916.  
  917.     <binding id="VideoFormat2Passes" extends="widgets.xml#widget">
  918.  
  919.         <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  920.             <vbox>
  921.                 <VideoFormat anonid="xVFP"/>
  922.                 <hbox>
  923.                     <checkbox anonid="x2Passes" 
  924.                         label="&label.video-format.two-passes;"
  925.                         oncommand="this.parentNode.parentNode.parentNode.changePassMode()"
  926.                         />
  927.                     <spacer flex="1"/>
  928.                     <menulist anonid="xPass"
  929.                         hidden="true"
  930.                         oncommand="this.parentNode.parentNode.parentNode.changePassNum()">
  931.                         <menupopup>
  932.                             <menuitem value="1" label="&label.video-format.first-pass;"/>
  933.                             <menuitem value="2" label="&label.video-format.second-pass;"/>
  934.                         </menupopup>
  935.                     </menulist>
  936.                 </hbox>
  937.             </vbox>
  938.             <children style="display: none;"/>
  939.         </xbl:content>
  940.  
  941.         <implementation>
  942.  
  943.             <constructor>
  944.                 <![CDATA[
  945.                 ]]>
  946.             </constructor>
  947.             
  948.             <method name="changePassMode">
  949.                 <body>
  950.                 <![CDATA[
  951. this.xPass.value="1";
  952. if(this.x2Passes.checked) {
  953.     var p=/.*?\/(.*)/.exec(this.xVFP.value)[1];
  954.     this._value=this.xVFP.value+"/"+p;
  955.     this.xPass.setAttribute("hidden","false");
  956. } else {
  957.     var p=this._value;
  958.     if(/.*\/.*\/.*/.test(this._value)) 
  959.         p=/(.*?\/.*?)\/.*/.exec(this._value)[1];
  960.     this._value=p;
  961.     this.xPass.setAttribute("hidden","true");
  962. }
  963.                 ]]>
  964.                 </body>
  965.             </method>
  966.  
  967.             <method name="changePassNum">
  968.                 <body>
  969.                 <![CDATA[
  970. if(this.xPass.value=="2") {
  971.     var p1=this.xVFP.value;
  972.     var m=/(.*?)\/.*?\/(.*)/.exec(this._value);
  973.     this._value=p1+"/"+m[2];
  974.     this.xVFP.value=m[1]+"/"+m[2];
  975. } else {
  976.     var p2=/.*?\/(.*)/.exec(this.xVFP.value)[1];
  977.     var p1=/(.*?\/.*?)\/.*/.exec(this._value)[1];
  978.     this._value=p1+"/"+p2;
  979.     this.xVFP.value=p1;
  980. }
  981. this.xVFP.secondPassMode(this.xPass.value=="2");
  982.                 ]]>
  983.                 </body>
  984.             </method>
  985.  
  986.             <property name="value">  
  987.                 <setter>
  988.                 <![CDATA[
  989. this._value=val;
  990. var p=val.split("/");
  991. if(p.length==2) {
  992.     this.x2Passes.checked=false;
  993.     this.xVFP.value=p[0]+"/"+p[1];
  994. } else {
  995.     this.x2Passes.checked=true;
  996.     this.changePassNum();
  997. }
  998. this.changePassMode();
  999.                 ]]> 
  1000.                 </setter>
  1001.                 <getter>
  1002.                 <![CDATA[
  1003. var value;
  1004. if(this.x2Passes.checked==false) {
  1005.     value=this.xVFP.value;
  1006. } else {
  1007.     if(this.xPass.value=="1") {
  1008.         var p2=/.*\/.*\/(.*)/.exec(this._value)[1];
  1009.         value=this.xVFP.value+"/"+p2;
  1010.     } else {
  1011.         var p1=/(.*?\/.*?)\/.*/.exec(this._value)[1];
  1012.         value=p1+"/"+this.xVFP.value;
  1013.     }
  1014. }
  1015. return value;
  1016.                 ]]> 
  1017.                 </getter>
  1018.             </property>
  1019.         </implementation>
  1020.  
  1021.     </binding>
  1022.  
  1023.  
  1024.     <binding id="NamedVideoFormat" extends="widgets.xml#widget">
  1025.  
  1026.         <xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  1027.             <vbox>
  1028.                 <FormatConfigList anonid="xList" confops="true" flex="1"/>
  1029.                 <VideoFormat2Passes anonid="xFormat" oncommand="this.parentNode.parentNode.configChanged()" onchange="this.parentNode.parentNode.configChanged()"/>
  1030.             </vbox>
  1031.             <children style="display: none;"/>
  1032.         </xbl:content>
  1033.  
  1034.         <implementation>
  1035.  
  1036.             <constructor>
  1037.                 <![CDATA[
  1038.                 ]]>
  1039.             </constructor>
  1040.  
  1041.             <destructor>
  1042.                 <![CDATA[
  1043.                 ]]>
  1044.             </destructor>
  1045.  
  1046.             <property name="value">  
  1047.                 <setter>
  1048.                 <![CDATA[
  1049. this.xFormat.value=val;
  1050. this.xList.value=val;
  1051.                 ]]> 
  1052.                 </setter>
  1053.                 <getter>
  1054.                 <![CDATA[
  1055. return this.xFormat.value;
  1056.                 ]]> 
  1057.                 </getter>
  1058.             </property>
  1059.             
  1060.             <method name="configChanged">
  1061.                 <body>
  1062.                 <![CDATA[
  1063. if(this.changeTimeout!=null)
  1064.     window.removeTimeout(this.changeTimeout);
  1065. this.changeTimeout=window.setTimeout(function(_t){_t.updateList();},250,this);
  1066.                 ]]>
  1067.                 </body>
  1068.             </method>
  1069.  
  1070.             <method name="updateList">
  1071.                 <parameter name="param"/>
  1072.                 <body>
  1073.                 <![CDATA[
  1074. this.changeTimeout=null;
  1075. this.xList.value=this.value;
  1076.                 ]]>
  1077.                 </body>
  1078.             </method>
  1079.  
  1080.             <method name="confSelected">
  1081.                 <body>
  1082.                 <![CDATA[
  1083. this.xFormat.value=this.xList.value;
  1084.                 ]]>
  1085.                 </body>
  1086.             </method>
  1087.  
  1088.  
  1089.         </implementation>
  1090.         
  1091.         <handlers>
  1092.             <handler event="dwhelper-confselect">
  1093.                 <![CDATA[
  1094. this.confSelected();
  1095.                 ]]>
  1096.             </handler>
  1097.         </handlers>
  1098.         
  1099.     </binding>
  1100.  
  1101.  
  1102. </bindings>
  1103.